<?php if (!defined('BASEPATH')) exit('No direct access allowed.');?>

<?php $this->load->view('common/header');?>

<body class="padding_top">
<!-- head [[-->
<div class="head_box">
    <div class="bank_nav">
        <a href="<?php echo site_url('member');?>"><i class="ico"></i></a>
    </div>
    <div class="head_title">实名认证</div>
</div>
<!--]] head -->
<!-- buy [[-->
<div class="certified_form">
    <dl>
        <dt>真实姓名</dt>
        <dd>
            <span class="input">
                <input id="user_uname" name="user_uname" placeholder="请输入您的真实姓名" value="<?php echo $user['user_uname'];?>">
            </span>
        </dd>
    </dl>
    <dl>
        <dt>身份证号</dt>
        <dd>
            <span class="input">
                <input id="user_card" name="user_card" placeholder="请输入真实有效身份证号码" value="<?php echo $user['user_card'];?>">
            </span>
        </dd>
    </dl>
    <dl>
        <dt>上传证件</dt>
        <dd>
            <span class="upload a_upload">
                <em>身份证<br>正面</em>
                <?php if(file_exists(FCPATH.'uploads/card/'.$user['user_id'].'/a_pic.jpg')){?>
                <img src="<?php echo base_url('uploads/card/'.$user['user_id'].'/a_pic.jpg?t='.time());?>">
                <?php }?>
            </span>
            <span class="upload b_upload">
                <em>身份证<br>反面</em>
                <?php if(file_exists(FCPATH.'uploads/card/'.$user['user_id'].'/b_pic.jpg')){?>
                <img src="<?php echo base_url('uploads/card/'.$user['user_id'].'/b_pic.jpg?t='.time());?>">
                <?php }?>
            </span>
        </dd>
    </dl>
    <dl>
        <dt>手持证件</dt>
        <dd>
            <span class="upload c_upload">
                <em>上传<br>征信报告</em>
                <?php if(file_exists(FCPATH.'uploads/card/'.$user['user_id'].'/c_pic.jpg')){?>
                <img src="<?php echo base_url('uploads/card/'.$user['user_id'].'/c_pic.jpg?t='.time());?>">
                <?php }?>
            </span>
            <span class="upload d_upload">
                <em>上传<br>公账流水</em>
                <?php if(file_exists(FCPATH.'uploads/card/'.$user['user_id'].'/d_pic.jpg')){?>
                    <img src="<?php echo base_url('uploads/card/'.$user['user_id'].'/d_pic.jpg?t='.time());?>">
                <?php }?>
            </span>
        </dd>
    </dl>
    <?php if(in_array($user['user_card_rz'],[0,3])){?>
    <dl class="sure_nav">
        <a href="javascript:;" class="sure_ok">
            <input type="submit">
            提交认证
        </a>
    </dl>
    <?php }?>
</div>
<!--]] buy -->
<?php if($user['user_card_rz']<2){?>
<script src="<?php echo $viewmulu;?>js/jquery.core.image.upload.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
    var uid = "<?php echo $user['user_id'];?>";
    $(".a_upload").coreImageUpload ({
        url: baseurl+'index.php/upload/upload_card?uid='+uid+'&name=a_pic',
        inputOfFile: 'a_pic',
        uploadedCallback: function (result) {
            if(result.status==1){
                var img = '<img src="'+result.url+'">';
                $(".a_upload img").remove();
                $(".a_upload em").remove();
                $(".a_upload").append(img);
            }else{
                layer.msg(result.msg,{offset:"80px"});
            }
        }
    });
    $(".b_upload").coreImageUpload ({
        url: baseurl+'index.php/upload/upload_card?uid='+uid+'&name=b_pic',
        inputOfFile: 'b_pic',
        uploadedCallback: function (result) {
            if(result.status==1){
                var img = '<img src="'+result.url+'">';
                $(".b_upload img").remove();
                $(".b_upload em").remove();
                $(".b_upload").append(img);
            }else{
                layer.msg(result.msg,{offset:"80px"});
            }
        }
    });
    $(".c_upload").coreImageUpload ({
        url: baseurl+'index.php/upload/upload_card?uid='+uid+'&name=c_pic',
        inputOfFile: 'c_pic',
        uploadedCallback: function (result) {
            if(result.status==1){
                var img = '<img src="'+result.url+'">';
                $(".c_upload img").remove();
                $(".c_upload em").remove();
                $(".c_upload").append(img);
            }else{
                layer.msg(result.msg,{offset:"80px"});
            }
        }
    });
    $(".d_upload").coreImageUpload ({
        url: baseurl+'index.php/upload/upload_card?uid='+uid+'&name=d_pic',
        inputOfFile: 'd_pic',
        uploadedCallback: function (result) {
            if(result.status==1){
                var img = '<img src="'+result.url+'">';
                $(".d_upload img").remove();
                $(".d_upload em").remove();
                $(".d_upload").append(img);
            }else{
                layer.msg(result.msg,{offset:"80px"});
            }
        }
    });
});
</script>
<script type="text/javascript">
    $(".sure_ok").click(function(){
        var user_uname = $("#user_uname").val();
        var user_card = $("#user_card").val();
        if(user_uname.length ==0){
            layer.msg("真实姓名不能为空",{offset:"80px"});
            return false;
        }
        if(user_card.length ==0){
            layer.msg("身份证号不能为空",{offset:"80px"});
            return false;
        }
        $.ajax({
            type : "post",
            url: baseurl+"index.php/member/verified",
            data: {'user_uname':user_uname,'user_card':user_card,'csrf_test_name': ci_csrf_token()},
            dataType:"JSON",
            success: function (msg) {
                if(msg.status==1){
                    layer.msg(msg.info, {
                        time: 1000, //1s后自动关闭
                        shade: 0.1
                    },function () {
                        window.location.href=baseurl+"index.php/member/index";
                    });
                }else{
                    layer.msg(msg.info);
                    return false;
                }
            }
        })
    });
</script>
<?php }?>
</body>
</html>